package server;

import util.MyParser;

public class ReceiveMonitor {
	private String message;

	public synchronized void setMessage(String input, String name) {
		try {
			while (this.message != null) {
				wait();
			}
			message = MyParser.concateFields(name, input);
			notifyAll();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

	}

	public synchronized String getMessage() {
		try {
			while (this.message == null) {
				wait();
			}
			String temp = message;
			message = null;
			notifyAll();
			return temp;
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return null;
	}

}
